﻿using DLLPC.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisionCore
{
    public class DI_Exc
    {
        private int Offset = 97;
        private int byteOffset = 0;
        private int Qty = 6;

        public void Update(byte[] DIStatus)
        {
            byteOffset = Offset;
            X020_CV1_Exist = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X021_CV1_Stop = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X022_CV1_Cyl_Up = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X023_CV1_Cyl_Dn = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X024 = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X025 = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X026_CV2_Exist = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X027_CV2_Stop = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset+1;
            X028_CV2_Cyl_Up = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X029_CV2_Cyl_Dn = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X02A =MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X02B = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X02C = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X02D = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X02E = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X02F = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset + 2;
            X030_1_Insp_Cyl_Up = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X031_1_Insp_Cyl_Dn = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X032_1_Insp_Vac = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X033_1_InspCV_Exist1 = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X034_1_InspCV_Exist2 = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X035_1_InspCV_Exist3 = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X036_1_InspStage_Exist = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X037_1_InspStage_Stop = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset + 3;
            X038_2_Insp_Cyl_Up = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X039_2_Insp_Cyl_Dn = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X03A_2_Insp_Vac = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X03B_2_InspCV_Exist1 = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X03C_2_InspCV_Exist2 = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X03D_2_InspCV_Exist3 = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X03E_2_InspStage_Exist = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X03F_2_InspStage_Stop = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset+4;
            X040_3_Insp_Cyl_Up = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X041_3_Insp_Cyl_Dn = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X042_3_Insp_Vac = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X043_3_InspCV_Exist1 = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X044_3_InspCV_Exist2 = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X045_3_InspCV_Exist3 = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X046_3_InspStage_Exist = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X047_3_InspStage_Stop = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset + 5;
            X048_4_Insp_Cyl_Up = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X049_4_Insp_Cyl_Dn = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X04A_4_Insp_Vac = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X04B_4_InspCV_Exist1 = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X04C_4_InspCV_Exist2 = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X04D_4_InspCV_Exist3 = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X04E_4_InspStage_Exist = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X04F_4_InspStage_Stop = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset + 6;
            X050 = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X051 = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X052 = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X053 = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X054 = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X055 = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X056 = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X057 = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset + 7;
            X058_DoorMonitor1 = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X059_DoorMonitor2 = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X05A_SourceAir = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X05B = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X05C = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X05D = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X05E = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X05F = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset+8;
            X060_UpStr1_SendReady = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X061_UpStr1_Sending = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X062_UpStr2_SendReady = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X063_UpStr2_Sending = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X064_UpStr3_SendReady = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X065_UpStr3_Sending = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X066_UpStr4_SendReady = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X067_UpStr4_Sending = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset + 9;
            X068_DnStr1_RevReady = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X069_DnStr1_Receiving = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X06A_DnStr2_RevReady = MemoryAccess.GetBit(DIStatus, byteOffset, 2);            
            X06B_DnStr2_Receiving = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X06C_DnStr3_RevReady = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X06D_DnStr3_Receiving = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X06E_DnStr4_RevReady = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X06F_DnStr4_Receiving = MemoryAccess.GetBit(DIStatus, byteOffset, 7);


            byteOffset = Offset + 10;
            X070 = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X071 = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X072 = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X073 = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X074 = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X075 = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X076 = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X077 = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            byteOffset = Offset + 11;
            X078 = MemoryAccess.GetBit(DIStatus, byteOffset, 0);
            X079 = MemoryAccess.GetBit(DIStatus, byteOffset, 1);
            X07A = MemoryAccess.GetBit(DIStatus, byteOffset, 2);
            X07B = MemoryAccess.GetBit(DIStatus, byteOffset, 3);
            X07C = MemoryAccess.GetBit(DIStatus, byteOffset, 4);
            X07D = MemoryAccess.GetBit(DIStatus, byteOffset, 5);
            X07E = MemoryAccess.GetBit(DIStatus, byteOffset, 6);
            X07F = MemoryAccess.GetBit(DIStatus, byteOffset, 7);

            for (int i = 0; i < Qty; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    Kernel.motion.DI.Datas[i * 8 + j] = MemoryAccess.GetBit(DIStatus, Offset + i, j);
                }
            }
        }

        #region OLD
        public byte X0C0_ExcST_Vac { get; set; } = 0;
        public byte X0C1_ExcST_Up { get; set; } = 0;
        public byte X0C2_ExcST_Down { get; set; } = 0;
        public byte X0C3_ExcTR_Up { get; set; } = 0;
        public byte X0C4_ExcTR_Down { get; set; } = 0;
        public byte X0C5_ExcTR_Ms_Up { get; set; } = 0;
        public byte X0C6_ExcTR_Ms_Down { get; set; } = 0;
        public byte X0C7_ExcTR_Close { get; set; } = 0;
        public byte X0C8_ExcTR_Open { get; set; } = 0;
        public byte X0C9_ExcTR_180 { get; set; } = 0;
        public byte X0CA_ExcTR_XSafeToR{ get; set; } = 0;
        public byte X0CB_ExcST_Presence { get; set; } = 0;
        public byte X0CC_SortST_OK_Vac { get; set; } = 0;
        public byte X0CD_SortST_Up { get; set; } = 0;
        public byte X0CE_SortST_Down { get; set; } = 0;
        public byte X0CF_SortST_NG_Vac { get; set; } = 0;
        public byte X0D0_SortST_XSafeToY { get; set; } = 0;
        public byte X0D1_Laser_Vac1 { get; set; } = 0;
        public byte X0D2_Laser_Vac2 { get; set; } = 0;
        public byte X0D3_Laser_Vac3 { get; set; } = 0;
        public byte X0D4_Laser_Vac4 { get; set; } = 0;
        public byte X0D5_Laser_Vac5 { get; set; } = 0;
        public byte X0D6_Laser_Vac6 { get; set; } = 0;
        public byte X0D7_Laser_Vac7 { get; set; } = 0;
        public byte X0D8_Laser_Vac8 { get; set; } = 0;
        public byte X0D9_ULDST_Vac{ get; set; } = 0;
        public byte X0DA_ULDST_Ext_Up { get; set; } = 0;
        public byte X0DB_ULDST_Ext_Down { get; set; } = 0;
        public byte X0DC_ULDST_Ball1_Up { get; set; } = 0;
        public byte X0DD_ULDST_Ball1_Down { get; set; } = 0;
        public byte X0DE_ULDST_Ball2_Up { get; set; } = 0;
        public byte X0DF_ULDST_Ball2_Down { get; set; } = 0;
        public byte X0E0_PowerON{ get; set; } = 0;
        public byte X0E1_EMO { get; set; } = 0;
        public byte X0E2_CDA { get; set; } = 0;
        public byte X0E3_VAC { get; set; } = 0;
        public byte X0E4_Door1 { get; set; } = 0;
        public byte X0E5_Door2 { get; set; } = 0;
        public byte X0E6_Door3 { get; set; } = 0;
        public byte X0E7_Door4 { get; set; } = 0;
        public byte X0E8_DoorLock { get; set; } = 0;
        public byte X0E9_Laser_Ms_Up { get; set; } = 0;
        public byte X0EA_Laser_Ms_Down { get; set; } = 0;
        public byte X0ED_SortST_YSafeToTRR { get; set; } = 0;
        public byte X0EB_ULDST_Presence { get; set; } = 0;
        public byte X0EC_ULDST_Protursion { get; set; } = 0;
        public byte X0EE_SortST_Presence { get; set; } = 0;
        public byte X0EF_SortST_YSafeforXtoHome { get; set; } = 0;
        public byte X0F0_SortST_NGLDReq { get; set; } = 0;
        public byte X0F1_SortST_NGLDComp { get; set; } = 0;
        public byte X0F2_ULDST_NGLDReq { get; set; } = 0;
        public byte X0F3_ULDST_NGULDReq { get; set; } = 0;
        public byte X0F4_ULDST_NGPresence { get; set; } = 0;
        public byte X0F5_SortST_NG_Up { get; set; } = 0;
        public byte X0F6_SortST_NG_Down { get; set; } = 0;
        public byte X0F7_LDTR1IonError { get; set; } = 0;
        public byte X0F8_LDTR2IonError { get; set; } = 0;
        public byte X0F9_ULDTR1IonError { get; set; } = 0;
        public byte X0FA_ULDTR2IonError { get; set; } = 0;
        public byte X0FB_ULDSTIonError { get; set; } = 0;
        public byte X0FC { get; set; } = 0;
        public byte X0FD { get; set; } = 0;
        public byte X0FE { get; set; } = 0;
        public byte X0FF { get; set; } = 0;

#endregion
        public byte X020_CV1_Exist { get; set; } = 0;
        public byte X021_CV1_Stop { get; set; } = 0;
        public byte X022_CV1_Cyl_Up { get; set; } = 0;
        public byte X023_CV1_Cyl_Dn{ get; set; } = 0;
        public byte X024 { get; set; } = 0;
        public byte X025 { get; set; } = 0;        
        public byte X026_CV2_Exist { get; set; } = 0;
        public byte X027_CV2_Stop { get; set; } = 0;
        public byte X028_CV2_Cyl_Up { get; set; } = 0;
        public byte X029_CV2_Cyl_Dn { get; set; } = 0;
        public byte X02A { get; set; } = 0;
        public byte X02B { get; set; } = 0;
        public byte X02C { get; set; } = 0;
        public byte X02D { get; set; } = 0;
        public byte X02E { get; set; } = 0;
        public byte X02F { get; set; } = 0;
        public byte X030_1_Insp_Cyl_Up { get; set; } = 0;
        public byte X031_1_Insp_Cyl_Dn { get; set; } = 0;
        public byte X032_1_Insp_Vac { get; set; } = 0;
        public byte X033_1_InspCV_Exist1 { get; set; } = 0;
        public byte X034_1_InspCV_Exist2 { get; set; } = 0;
        public byte X035_1_InspCV_Exist3 { get; set; } = 0;
        public byte X036_1_InspStage_Exist { get; set; } = 0;
        public byte X037_1_InspStage_Stop { get; set; } = 0;
        public byte X038_2_Insp_Cyl_Up { get; set; } = 0;
        public byte X039_2_Insp_Cyl_Dn { get; set; } = 0;
        public byte X03A_2_Insp_Vac { get; set; } = 0;
        public byte X03B_2_InspCV_Exist1 { get; set; } = 0;
        public byte X03C_2_InspCV_Exist2 { get; set; } = 0;
        public byte X03D_2_InspCV_Exist3 { get; set; } = 0;
        public byte X03E_2_InspStage_Exist { get; set; } = 0;
        public byte X03F_2_InspStage_Stop { get; set; } = 0;
        public byte X040_3_Insp_Cyl_Up { get; set; } = 0;
        public byte X041_3_Insp_Cyl_Dn { get; set; } = 0;
        public byte X042_3_Insp_Vac { get; set; } = 0;
        public byte X043_3_InspCV_Exist1 { get; set; } = 0;
        public byte X044_3_InspCV_Exist2 { get; set; } = 0;
        public byte X045_3_InspCV_Exist3 { get; set; } = 0;
        public byte X046_3_InspStage_Exist { get; set; } = 0;
        public byte X047_3_InspStage_Stop { get; set; } = 0;
        public byte X048_4_Insp_Cyl_Up { get; set; } = 0;
        public byte X049_4_Insp_Cyl_Dn { get; set; } = 0;
        public byte X04A_4_Insp_Vac { get; set; } = 0;
        public byte X04B_4_InspCV_Exist1 { get; set; } = 0;
        public byte X04C_4_InspCV_Exist2 { get; set; } = 0;
        public byte X04D_4_InspCV_Exist3 { get; set; } = 0;
        public byte X04E_4_InspStage_Exist { get; set; } = 0;
        public byte X04F_4_InspStage_Stop { get; set; } = 0;
        public byte X050{ get; set; } = 0;
        public byte X051{ get; set; } = 0;
        public byte X052{ get; set; } = 0;
        public byte X053 { get; set; } = 0;
        public byte X054{ get; set; } = 0;
        public byte X055{ get; set; } = 0;
        public byte X056{ get; set; } = 0;
        public byte X057 { get; set; } = 0;
        public byte X058_DoorMonitor1{ get; set; } = 0;
        public byte X059_DoorMonitor2{ get; set; } = 0;
        public byte X05A_SourceAir{ get; set; } = 0;
        public byte X05B { get; set; } = 0;
        public byte X05C{ get; set; } = 0;
        public byte X05D{ get; set; } = 0;
        public byte X05E{ get; set; } = 0;
        public byte X05F { get; set; } = 0;
        public byte X060_UpStr1_SendReady{ get; set; } = 0;
        public byte X061_UpStr1_Sending{ get; set; } = 0;
        public byte X062_UpStr2_SendReady{ get; set; } = 0;
        public byte X063_UpStr2_Sending{ get; set; } = 0;
        public byte X064_UpStr3_SendReady{ get; set; } = 0;
        public byte X065_UpStr3_Sending{ get; set; } = 0;
        public byte X066_UpStr4_SendReady{ get; set; } = 0;
        public byte X067_UpStr4_Sending { get; set; } = 0;
        public byte X068_DnStr1_RevReady{ get; set; } = 0;
        public byte X069_DnStr1_Receiving{ get; set; } = 0;
        public byte X06A_DnStr2_RevReady{ get; set; } = 0;
        public byte X06B_DnStr2_Receiving { get; set; } = 0;
        public byte X06C_DnStr3_RevReady{ get; set; } = 0;
        public byte X06D_DnStr3_Receiving{ get; set; } = 0;
        public byte X06E_DnStr4_RevReady{ get; set; } = 0;
        public byte X06F_DnStr4_Receiving { get; set; } = 0;
        public byte X070 { get; set; } = 0;
        public byte X071 { get; set; } = 0;
        public byte X072 { get; set; } = 0;
        public byte X073 { get; set; } = 0;
        public byte X074 { get; set; } = 0;
        public byte X075 { get; set; } = 0;
        public byte X076 { get; set; } = 0;
        public byte X077 { get; set; } = 0;
        public byte X078 { get; set; } = 0;
        public byte X079 { get; set; } = 0;
        public byte X07A { get; set; } = 0;
        public byte X07B { get; set; } = 0;
        public byte X07C { get; set; } = 0;
        public byte X07D { get; set; } = 0;
        public byte X07E { get; set; } = 0;
        public byte X07F { get; set; } = 0;       
    }

    public class DO_Exc
    {
        private int Offset = 65;
        private int byteOffset = 0;
        private int Qty = 4;

        public byte[] Update(byte[] DOStatus)
        {
            byteOffset = Offset;
            MemoryAccess.SetBit(ref DOStatus, Y020, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y021, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y022_1_CV_Cyl_Up, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y023_1_CV_Cyl_Dn, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y024, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y025, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y026, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y027, byteOffset, 7);

            byteOffset = Offset + 1;
            MemoryAccess.SetBit(ref DOStatus, Y028_2_CV_Cyl_Up, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y029_2_CV_Cyl_Dn, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y02A, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y02B, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y02C, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y02D, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y02E, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y02F, byteOffset, 7);

            byteOffset = Offset + 2;
            MemoryAccess.SetBit(ref DOStatus, Y030_1_Insp_Cyl_Up, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y031_1_Insp_Cyl_Dn, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y032_1_Insp_Vacuum, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y033_1_Insp_VacBrk, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y034_1_InspLight_Ctr1, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y035_1_InspLight_Ctr2, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y036, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y037, byteOffset, 7);

            byteOffset = Offset + 3;
            MemoryAccess.SetBit(ref DOStatus, Y038_2_Insp_Cyl_Up, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y039_2_Insp_Cyl_Dn, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y03A_2_Insp_Vacuum, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y03B_2_Insp_VacBrk, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y03C, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y03D, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y03E, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y03F, byteOffset, 7);

            byteOffset = Offset + 4;
            MemoryAccess.SetBit(ref DOStatus, Y040_3_Insp_Cyl_Up, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y041_3_Insp_Cyl_Dn, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y042_3_Insp_Vacuum, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y043_3_Insp_VacBrk, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y044_2_InspLight_Ctr1, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y045_2_InspLight_Ctr2, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y046, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y047, byteOffset, 7);

            byteOffset = Offset + 5;
            MemoryAccess.SetBit(ref DOStatus, Y048_4_Insp_Cyl_Up, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y049_4_Insp_Cyl_Dn, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y04A_4_Insp_Vacuum, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y04B_4_Insp_VacBrk, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y04C, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y04D, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y04E, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y04F, byteOffset, 7);

            byteOffset = Offset + 6;
            MemoryAccess.SetBit(ref DOStatus, Y050, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y051, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y052, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y053, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y054, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y055, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y056, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y057_DoorUnLock, byteOffset, 7);

            byteOffset = Offset + 7;
            MemoryAccess.SetBit(ref DOStatus, Y058_SafeDoor1_Lock, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y059_SafeDoor2_Lock, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y05A_SunLightLamp_Ctr, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y05B_FourColor_Lamp_Y, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y05C_FourColor_Lamp_G, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y05D_FourColor_Lamp_R, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y05E_FourColor_Lamp_B, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y05F_FourColor_Buzzer, byteOffset, 7);

            byteOffset = Offset + 8;
            MemoryAccess.SetBit(ref DOStatus, Y060_UpStr_CH1_Rev_Ready, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y061_UpStr_CH1_receiving, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y062_UpStr_CH2_Rev_Ready, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y063_UpStr_CH2_receiving, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y064_UpStr_CH3_Rev_Ready, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y065_UpStr_CH3_receiving, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y066_UpStr_CH4_Rev_Ready, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y067_UpStr_CH4_receiving, byteOffset, 7);

            byteOffset = Offset + 9;
            MemoryAccess.SetBit(ref DOStatus, Y068_DnStr_CH1_SendReady, byteOffset, 0);
            MemoryAccess.SetBit(ref DOStatus, Y069_DnStr_CH1_Sending, byteOffset, 1);
            MemoryAccess.SetBit(ref DOStatus, Y06A_DnStr_CH2_SendReady, byteOffset, 2);
            MemoryAccess.SetBit(ref DOStatus, Y06B_DnStr_CH2_Sending, byteOffset, 3);
            MemoryAccess.SetBit(ref DOStatus, Y06C_DnStr_CH3_SendReady, byteOffset, 4);
            MemoryAccess.SetBit(ref DOStatus, Y06D_DnStr_CH3_Sending, byteOffset, 5);
            MemoryAccess.SetBit(ref DOStatus, Y06E_DnStr_CH4_SendReady, byteOffset, 6);
            MemoryAccess.SetBit(ref DOStatus, Y06F_DnStr_CH4_Sending, byteOffset, 7);

            //byteOffset = Offset + 10;
            //MemoryAccess.SetBit(ref DOStatus, Y070_DnStr_ready, byteOffset, 0);
            //MemoryAccess.SetBit(ref DOStatus, Y071_DnStr_sending, byteOffset, 1);
            //MemoryAccess.SetBit(ref DOStatus, Y072_DnStr_work_transfer, byteOffset, 2);
            //MemoryAccess.SetBit(ref DOStatus, Y073_DnStr_sending_canel, byteOffset, 3);
            //MemoryAccess.SetBit(ref DOStatus, Y074, byteOffset, 4);
            //MemoryAccess.SetBit(ref DOStatus, Y075, byteOffset, 5);
            //MemoryAccess.SetBit(ref DOStatus, Y076, byteOffset, 6);
            //MemoryAccess.SetBit(ref DOStatus, Y077, byteOffset, 7);

            //byteOffset = Offset + 11;
            //MemoryAccess.SetBit(ref DOStatus, Y078, byteOffset, 0);
            //MemoryAccess.SetBit(ref DOStatus, Y079, byteOffset, 1);
            //MemoryAccess.SetBit(ref DOStatus, Y07A, byteOffset, 2);
            //MemoryAccess.SetBit(ref DOStatus, Y07B, byteOffset, 3);
            //MemoryAccess.SetBit(ref DOStatus, Y07C, byteOffset, 4);
            //MemoryAccess.SetBit(ref DOStatus, Y07D, byteOffset, 5);
            //MemoryAccess.SetBit(ref DOStatus, Y07E, byteOffset, 6);
            //MemoryAccess.SetBit(ref DOStatus, Y07F, byteOffset, 7);
            for (int i = 0; i < Qty; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    Kernel.motion.DO.Datas[(i * 8 ) + j] = MemoryAccess.GetBit(DOStatus, Offset + i, j);
                }
            }

            return DOStatus;
        }


        #region  OLD
        public byte Y1C0_ExcST_VacOn { get; set; } = 0;
        public byte Y1C1_ExcST_Up { get; set; } = 0;
        public byte Y1C2 { get; set; } = 0;
        public byte Y1C3_ExcTR_Up{ get; set; } = 0;
        public byte Y1C4_ExcTR_Down { get; set; } = 0;
        public byte Y1C5 { get; set; } = 0;
        public byte Y1C6_ExcTR_Ms_Down { get; set; } = 0;
        public byte Y1C7_ExcTR_Close { get; set; } = 0;
        public byte Y1C8_LDTR1_Blow { get; set; } = 0;
        public byte Y1C9_LDTR2_Blow { get; set; } = 0;
        public byte Y1CA_ULDTR1_Blow { get; set; } = 0;
        public byte Y1CB_ULDTR2_Blow { get; set; } = 0;
        public byte Y1CC_SortST_OK_VacON { get; set; } = 0;
        public byte Y1CD_SortST_Up { get; set; } = 0;
        public byte Y1CE { get; set; } = 0;
        public byte Y1CF_SortST_NG_VacON { get; set; } = 0;
        public byte Y1D0 { get; set; } = 0;
        public byte Y1D1_Laser_Vac1 { get; set; } = 0;
        public byte Y1D2_Laser_Vac2 { get; set; } = 0;
        public byte Y1D3_Laser_Vac3 { get; set; } = 0;
        public byte Y1D4_Laser_Vac4 { get; set; } = 0;
        public byte Y1D5_Laser_Vac5 { get; set; } = 0;
        public byte Y1D6_Laser_Vac6 { get; set; } = 0;
        public byte Y1D7_Laser_Vac7 { get; set; } = 0;
        public byte Y1D8_Laser_Vac8{ get; set; } = 0;
        public byte Y1D9_ULDST_Vac { get; set; } = 0;
        public byte Y1DA_ULDST_Ext_Up { get; set; } = 0;
        public byte Y1DB { get; set; } = 0;
        public byte Y1DC_ULDST_Ball1_Up { get; set; } = 0;
        public byte Y1DD { get; set; } = 0;
        public byte Y1DE_ULDST_DieVac { get; set; } = 0;
        public byte Y1DF { get; set; } = 0;
        public byte Y1E0_Lamp_R { get; set; } = 0;
        public byte Y1E1_Lamp_Y { get; set; } = 0;
        public byte Y1E2_Lamp_G { get; set; } = 0;
        public byte Y1E3_Buzzer { get; set; } = 0;
        public byte Y1E4_DoorLock1 { get; set; } = 0;
        public byte Y1E5_DoorLock2 { get; set; } = 0;
        public byte Y1E6_DoorLock3 { get; set; } = 0;
        public byte Y1E7_DoorLock4 { get; set; } = 0;
        public byte Y1E8_DoorRst { get; set; } = 0;
        public byte Y1E9_DoorLock5 { get; set; } = 0;
        public byte Y1EA_Laser_Ms_Down { get; set; } = 0;
        public byte Y1EB { get; set; } = 0;
        public byte Y1EC { get; set; } = 0;
        public byte Y1ED { get; set; } = 0;
        public byte Y1EE_ExcST_CodeReadLight { get; set; } = 0;
        public byte Y1EF_Light_Open { get; set; } = 0;
        public byte Y1F0_BallLight_Exc { get; set; } = 0;
        public byte Y1F1_CoaxialLight_Exc { get; set; } = 0;
        public byte Y1F2_PreAlignLight_SortST { get; set; } = 0;
        public byte Y1F3_FinalAlignLight_SortST { get; set; } = 0;
        public byte Y1F4_UpperCoaxialLight_Laser { get; set; } = 0;
        public byte Y1F5_SideCoaxialLight_Laser { get; set; } = 0;
        public byte Y1F6_InspCoaxialLight_Laser { get; set; } = 0;
        public byte Y1F7_AlignLight_ULDTR1 { get; set; } = 0;
        public byte Y1F8_AlignLight_ULDTR2 { get; set; } = 0;
        public byte Y1F9_PreAlignLight_ULDST { get; set; } = 0;
        public byte Y1FA_FinalAlignLight_ULDST { get; set; } = 0;
        public byte Y1FB_RingLight_Efem { get; set; } = 0;
        public byte Y1FC_CoaxialLight_Efem { get; set; } = 0;
        public byte Y1FD_UpperBallLight_Laser { get; set; } = 0;
        public byte Y1FE_SideBackLight_Laser { get; set; } = 0;
        public byte Y1FF_InspBallLight_Laser { get; set; } = 0;
        public byte Y200_SortST_NGLDReq_BL { get; set; } = 0;
        public byte Y201_SortST_NGLDComp_BL { get; set; } = 0;
        public byte Y202_ULDST_NGLDReq_BL { get; set; } = 0;
        public byte Y203_ULDST_NGULDReq_BL { get; set; } = 0;
        public byte Y204 { get; set; } = 0;
        public byte Y205_SortST_NG_Up { get; set; } = 0;
        public byte Y206 { get; set; } = 0;
        public byte Y207_ExcIon_Open { get; set; } = 0;
        public byte Y208 { get; set; } = 0;
        public byte Y209 { get; set; } = 0;
        public byte Y20A { get; set; } = 0;
        public byte Y20B { get; set; } = 0;
        public byte Y20C { get; set; } = 0;
        public byte Y20D { get; set; } = 0;
        public byte Y20E { get; set; } = 0;
        public byte Y20F { get; set; } = 0;
        #endregion

        public byte Y020{ get; set; } = 0;
        public byte Y021{ get; set; } = 0;
        public byte Y022_1_CV_Cyl_Up{ get; set; } = 0;
        public byte Y023_1_CV_Cyl_Dn{ get; set; } = 0;
        public byte Y024{ get; set; } = 0;
        public byte Y025{ get; set; } = 0;
        public byte Y026{ get; set; } = 0;
        public byte Y027 { get; set; } = 0;
        public byte Y028_2_CV_Cyl_Up{ get; set; } = 0;
        public byte Y029_2_CV_Cyl_Dn{ get; set; } = 0;
        public byte Y02A{ get; set; } = 0;
        public byte Y02B{ get; set; } = 0;
        public byte Y02C{ get; set; } = 0;
        public byte Y02D{ get; set; } = 0;
        public byte Y02E{ get; set; } = 0;
        public byte Y02F { get; set; } = 0;
        public byte Y030_1_Insp_Cyl_Up{ get; set; } = 0;
        public byte Y031_1_Insp_Cyl_Dn{ get; set; } = 0;
        public byte Y032_1_Insp_Vacuum{ get; set; } = 0;
        public byte Y033_1_Insp_VacBrk{ get; set; } = 0;
        public byte Y034_1_InspLight_Ctr1{ get; set; } = 0;
        public byte Y035_1_InspLight_Ctr2{ get; set; } = 0;
        public byte Y036{ get; set; } = 0;
        public byte Y037 { get; set; } = 0;
        public byte Y038_2_Insp_Cyl_Up{ get; set; } = 0;
        public byte Y039_2_Insp_Cyl_Dn{ get; set; } = 0;
        public byte Y03A_2_Insp_Vacuum{ get; set; } = 0;
        public byte Y03B_2_Insp_VacBrk{ get; set; } = 0;
        public byte Y03C{ get; set; } = 0;
        public byte Y03D{ get; set; } = 0;
        public byte Y03E{ get; set; } = 0;
        public byte Y03F { get; set; } = 0;
        public byte Y040_3_Insp_Cyl_Up{ get; set; } = 0;
        public byte Y041_3_Insp_Cyl_Dn{ get; set; } = 0;
        public byte Y042_3_Insp_Vacuum{ get; set; } = 0;
        public byte Y043_3_Insp_VacBrk{ get; set; } = 0;
        public byte Y044_2_InspLight_Ctr1{ get; set; } = 0;
        public byte Y045_2_InspLight_Ctr2{ get; set; } = 0;
        public byte Y046{ get; set; } = 0;
        public byte Y047 { get; set; } = 0;
        public byte Y048_4_Insp_Cyl_Up{ get; set; } = 0;
        public byte Y049_4_Insp_Cyl_Dn{ get; set; } = 0;
        public byte Y04A_4_Insp_Vacuum{ get; set; } = 0;
        public byte Y04B_4_Insp_VacBrk{ get; set; } = 0;
        public byte Y04C{ get; set; } = 0;
        public byte Y04D{ get; set; } = 0;
        public byte Y04E{ get; set; } = 0;
        public byte Y04F { get; set; } = 0;
        public byte Y050{ get; set; } = 0;
        public byte Y051 { get; set; } = 0;
        public byte Y052 { get; set; } = 0;
        public byte Y053 { get; set; } = 0;
        public byte Y054 { get; set; } = 0;
        public byte Y055 { get; set; } = 0;
        public byte Y056 { get; set; } = 0;
        public byte Y057_DoorUnLock { get; set; } = 0;
        public byte Y058_SafeDoor1_Lock{ get; set; } = 0;
        public byte Y059_SafeDoor2_Lock{ get; set; } = 0;
        public byte Y05A_SunLightLamp_Ctr{ get; set; } = 0;
        public byte Y05B_FourColor_Lamp_Y{ get; set; } = 0;
        public byte Y05C_FourColor_Lamp_G{ get; set; } = 0;
        public byte Y05D_FourColor_Lamp_R{ get; set; } = 0;
        public byte Y05E_FourColor_Lamp_B{ get; set; } = 0;
        public byte Y05F_FourColor_Buzzer { get; set; } = 0;
        public byte Y060_UpStr_CH1_Rev_Ready{ get; set; } = 0;
        public byte Y061_UpStr_CH1_receiving{ get; set; } = 0;
        public byte Y062_UpStr_CH2_Rev_Ready { get; set; } = 0;
        public byte Y063_UpStr_CH2_receiving{ get; set; } = 0;
        public byte Y064_UpStr_CH3_Rev_Ready{ get; set; } = 0;
        public byte Y065_UpStr_CH3_receiving{ get; set; } = 0;
        public byte Y066_UpStr_CH4_Rev_Ready { get; set; } = 0;
        public byte Y067_UpStr_CH4_receiving { get; set; } = 0;
        public byte Y068_DnStr_CH1_SendReady { get; set; } = 0;
        public byte Y069_DnStr_CH1_Sending { get; set; } = 0;
        public byte Y06A_DnStr_CH2_SendReady { get; set; } = 0;
        public byte Y06B_DnStr_CH2_Sending { get; set; } = 0;
        public byte Y06C_DnStr_CH3_SendReady { get; set; } = 0;
        public byte Y06D_DnStr_CH3_Sending { get; set; } = 0;
        public byte Y06E_DnStr_CH4_SendReady { get; set; } = 0;
        public byte Y06F_DnStr_CH4_Sending { get; set; } = 0;
        //public byte Y070_DnStr_ready { get; set; } = 0;
        //public byte Y071_DnStr_sending { get; set; } = 0;
        //public byte Y072_DnStr_work_transfer { get; set; } = 0;
        //public byte Y073_DnStr_sending_canel { get; set; } = 0;
        //public byte Y074 { get; set; } = 0;
        //public byte Y075 { get; set; } = 0;
        //public byte Y076 { get; set; } = 0;
        //public byte Y077 { get; set; } = 0;
        //public byte Y078 { get; set; } = 0;
        //public byte Y079 { get; set; } = 0;
        //public byte Y07A { get; set; } = 0;
        //public byte Y07B { get; set; } = 0;
        //public byte Y07C { get; set; } = 0;
        //public byte Y07D { get; set; } = 0;
        //public byte Y07E { get; set; } = 0;
        //public byte Y07F { get; set; } = 0;
    }

    public class Ao_Exc
    {
        public float[] Update(float[] AoStatus)
        {
            AoStatus[0] = CH1;
            AoStatus[1] = CH2;
            AoStatus[2] = CH3;
            AoStatus[3] = CH4;

            return AoStatus;
        }

        /// <summary>
        /// 0~10V
        /// </summary>
        public float CH1 { get; set; } = 2;
        /// <summary>
        /// 0~10V
        /// </summary>
        public float CH2 { get; set; } = 0;
        /// <summary>
        /// 0~10V
        /// </summary>
        public float CH3 { get; set; } = 0;
        /// <summary>
        /// 0~10V
        /// </summary>
        public float CH4 { get; set; } = 0;
    }
}
